Optimal. Leaf size=126 \[ -\frac {(b (c-d)-a (c+d)) (a (c-d)+b (c+d)) x}{\left (a^2+b^2\right )^2}+\frac {2 (b c-a d) (a c+b d) \log (a \cos (e+f x)+b \sin (e+f x))}{\left (a^2+b^2\right )^2 f}-\frac {(b c-a d)^2}{b \left (a^2+b^2\right ) f (a+b \tan (e+f x))} \]
[Out]
________________________________________________________________________________________
Rubi [A]
time = 0.16, antiderivative size = 126, normalized size of antiderivative = 1.00, number of steps
used = 3, number of rules used = 3, integrand size = 25, \(\frac {\text {number of rules}}{\text {integrand size}}\) = 0.120, Rules used = {3623, 3612,
3611} \begin {gather*} -\frac {(b c-a d)^2}{b f \left (a^2+b^2\right ) (a+b \tan (e+f x))}+\frac {2 (a c+b d) (b c-a d) \log (a \cos (e+f x)+b \sin (e+f x))}{f \left (a^2+b^2\right )^2}-\frac {x (b (c-d)-a (c+d)) (a (c-d)+b (c+d))}{\left (a^2+b^2\right )^2} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
Rule 3611
Rule 3612
Rule 3623
Rubi steps
\begin {align*} \int \frac {(c+d \tan (e+f x))^2}{(a+b \tan (e+f x))^2} \, dx &=-\frac {(b c-a d)^2}{b \left (a^2+b^2\right ) f (a+b \tan (e+f x))}+\frac {\int \frac {2 b c d+a \left (c^2-d^2\right )+\left (2 a c d-b \left (c^2-d^2\right )\right ) \tan (e+f x)}{a+b \tan (e+f x)} \, dx}{a^2+b^2}\\ &=-\frac {(b (c-d)-a (c+d)) (a (c-d)+b (c+d)) x}{\left (a^2+b^2\right )^2}-\frac {(b c-a d)^2}{b \left (a^2+b^2\right ) f (a+b \tan (e+f x))}+\frac {(2 (b c-a d) (a c+b d)) \int \frac {b-a \tan (e+f x)}{a+b \tan (e+f x)} \, dx}{\left (a^2+b^2\right )^2}\\ &=-\frac {(b (c-d)-a (c+d)) (a (c-d)+b (c+d)) x}{\left (a^2+b^2\right )^2}+\frac {2 (b c-a d) (a c+b d) \log (a \cos (e+f x)+b \sin (e+f x))}{\left (a^2+b^2\right )^2 f}-\frac {(b c-a d)^2}{b \left (a^2+b^2\right ) f (a+b \tan (e+f x))}\\ \end {align*}
________________________________________________________________________________________
Mathematica [C] Result contains complex when optimal does not.
time = 2.15, size = 321, normalized size = 2.55 \begin {gather*} \frac {(a \cos (e+f x)+b \sin (e+f x)) \left (\frac {\left (a^2+b^2\right ) (b c-a d)^2 \sin (e+f x)}{a}+(b (-c+d)+a (c+d)) (a (c-d)+b (c+d)) (e+f x) (a \cos (e+f x)+b \sin (e+f x))-2 i \left (a^2 c d-b^2 c d+a b \left (-c^2+d^2\right )\right ) (e+f x) (a \cos (e+f x)+b \sin (e+f x))+2 i \left (a^2 c d-b^2 c d+a b \left (-c^2+d^2\right )\right ) \text {ArcTan}(\tan (e+f x)) (a \cos (e+f x)+b \sin (e+f x))-\left (a^2 c d-b^2 c d+a b \left (-c^2+d^2\right )\right ) \log \left ((a \cos (e+f x)+b \sin (e+f x))^2\right ) (a \cos (e+f x)+b \sin (e+f x))\right ) (c+d \tan (e+f x))^2}{\left (a^2+b^2\right )^2 f (c \cos (e+f x)+d \sin (e+f x))^2 (a+b \tan (e+f x))^2} \end {gather*}
Antiderivative was successfully verified.
[In]
[Out]
________________________________________________________________________________________
Maple [A]
time = 0.22, size = 200, normalized size = 1.59
method | result | size |
derivativedivides | \(\frac {-\frac {a^{2} d^{2}-2 a b c d +b^{2} c^{2}}{\left (a^{2}+b^{2}\right ) b \left (a +b \tan \left (f x +e \right )\right )}-\frac {2 \left (a^{2} c d -a b \,c^{2}+a b \,d^{2}-b^{2} c d \right ) \ln \left (a +b \tan \left (f x +e \right )\right )}{\left (a^{2}+b^{2}\right )^{2}}+\frac {\frac {\left (2 a^{2} c d -2 a b \,c^{2}+2 a b \,d^{2}-2 b^{2} c d \right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{2}+\left (a^{2} c^{2}-a^{2} d^{2}+4 a b c d -b^{2} c^{2}+b^{2} d^{2}\right ) \arctan \left (\tan \left (f x +e \right )\right )}{\left (a^{2}+b^{2}\right )^{2}}}{f}\) | \(200\) |
default | \(\frac {-\frac {a^{2} d^{2}-2 a b c d +b^{2} c^{2}}{\left (a^{2}+b^{2}\right ) b \left (a +b \tan \left (f x +e \right )\right )}-\frac {2 \left (a^{2} c d -a b \,c^{2}+a b \,d^{2}-b^{2} c d \right ) \ln \left (a +b \tan \left (f x +e \right )\right )}{\left (a^{2}+b^{2}\right )^{2}}+\frac {\frac {\left (2 a^{2} c d -2 a b \,c^{2}+2 a b \,d^{2}-2 b^{2} c d \right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{2}+\left (a^{2} c^{2}-a^{2} d^{2}+4 a b c d -b^{2} c^{2}+b^{2} d^{2}\right ) \arctan \left (\tan \left (f x +e \right )\right )}{\left (a^{2}+b^{2}\right )^{2}}}{f}\) | \(200\) |
norman | \(\frac {\frac {a \left (a^{2} c^{2}-a^{2} d^{2}+4 a b c d -b^{2} c^{2}+b^{2} d^{2}\right ) x}{a^{4}+2 a^{2} b^{2}+b^{4}}+\frac {b \left (a^{2} c^{2}-a^{2} d^{2}+4 a b c d -b^{2} c^{2}+b^{2} d^{2}\right ) x \tan \left (f x +e \right )}{a^{4}+2 a^{2} b^{2}+b^{4}}+\frac {\left (a^{2} d^{2}-2 a b c d +b^{2} c^{2}\right ) \tan \left (f x +e \right )}{a f \left (a^{2}+b^{2}\right )}}{a +b \tan \left (f x +e \right )}+\frac {\left (a^{2} c d -a b \,c^{2}+a b \,d^{2}-b^{2} c d \right ) \ln \left (1+\tan ^{2}\left (f x +e \right )\right )}{f \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}-\frac {2 \left (a^{2} c d -a b \,c^{2}+a b \,d^{2}-b^{2} c d \right ) \ln \left (a +b \tan \left (f x +e \right )\right )}{f \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}\) | \(298\) |
risch | \(\frac {4 i a^{2} c d e}{f \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}-\frac {x \,c^{2}}{2 i a b -a^{2}+b^{2}}+\frac {x \,d^{2}}{2 i a b -a^{2}+b^{2}}+\frac {2 i x c d}{2 i a b -a^{2}+b^{2}}+\frac {2 i a^{2} d^{2}}{\left (i b +a \right ) f \left (-i b +a \right )^{2} \left (-i {\mathrm e}^{2 i \left (f x +e \right )} b +{\mathrm e}^{2 i \left (f x +e \right )} a +i b +a \right )}-\frac {4 i a b \,c^{2} x}{a^{4}+2 a^{2} b^{2}+b^{4}}-\frac {4 i b^{2} c d x}{a^{4}+2 a^{2} b^{2}+b^{4}}+\frac {4 i a b \,d^{2} e}{f \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}+\frac {2 i b^{2} c^{2}}{\left (i b +a \right ) f \left (-i b +a \right )^{2} \left (-i {\mathrm e}^{2 i \left (f x +e \right )} b +{\mathrm e}^{2 i \left (f x +e \right )} a +i b +a \right )}+\frac {4 i a^{2} c d x}{a^{4}+2 a^{2} b^{2}+b^{4}}-\frac {4 i a b c d}{\left (i b +a \right ) f \left (-i b +a \right )^{2} \left (-i {\mathrm e}^{2 i \left (f x +e \right )} b +{\mathrm e}^{2 i \left (f x +e \right )} a +i b +a \right )}+\frac {4 i a b \,d^{2} x}{a^{4}+2 a^{2} b^{2}+b^{4}}-\frac {4 i b^{2} c d e}{f \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}-\frac {4 i a b \,c^{2} e}{f \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}-\frac {2 \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}-\frac {i b +a}{i b -a}\right ) a^{2} c d}{f \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}+\frac {2 \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}-\frac {i b +a}{i b -a}\right ) a b \,c^{2}}{f \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}-\frac {2 \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}-\frac {i b +a}{i b -a}\right ) a b \,d^{2}}{f \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}+\frac {2 \ln \left ({\mathrm e}^{2 i \left (f x +e \right )}-\frac {i b +a}{i b -a}\right ) b^{2} c d}{f \left (a^{4}+2 a^{2} b^{2}+b^{4}\right )}\) | \(689\) |
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Maxima [A]
time = 0.57, size = 234, normalized size = 1.86 \begin {gather*} \frac {\frac {{\left (4 \, a b c d + {\left (a^{2} - b^{2}\right )} c^{2} - {\left (a^{2} - b^{2}\right )} d^{2}\right )} {\left (f x + e\right )}}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} + \frac {2 \, {\left (a b c^{2} - a b d^{2} - {\left (a^{2} - b^{2}\right )} c d\right )} \log \left (b \tan \left (f x + e\right ) + a\right )}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} - \frac {{\left (a b c^{2} - a b d^{2} - {\left (a^{2} - b^{2}\right )} c d\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} - \frac {b^{2} c^{2} - 2 \, a b c d + a^{2} d^{2}}{a^{3} b + a b^{3} + {\left (a^{2} b^{2} + b^{4}\right )} \tan \left (f x + e\right )}}{f} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Fricas [B] Leaf count of result is larger than twice the leaf count of optimal. 310 vs.
\(2 (128) = 256\).
time = 0.93, size = 310, normalized size = 2.46 \begin {gather*} -\frac {b^{3} c^{2} - 2 \, a b^{2} c d + a^{2} b d^{2} - {\left (4 \, a^{2} b c d + {\left (a^{3} - a b^{2}\right )} c^{2} - {\left (a^{3} - a b^{2}\right )} d^{2}\right )} f x - {\left (a^{2} b c^{2} - a^{2} b d^{2} - {\left (a^{3} - a b^{2}\right )} c d + {\left (a b^{2} c^{2} - a b^{2} d^{2} - {\left (a^{2} b - b^{3}\right )} c d\right )} \tan \left (f x + e\right )\right )} \log \left (\frac {b^{2} \tan \left (f x + e\right )^{2} + 2 \, a b \tan \left (f x + e\right ) + a^{2}}{\tan \left (f x + e\right )^{2} + 1}\right ) - {\left (a b^{2} c^{2} - 2 \, a^{2} b c d + a^{3} d^{2} + {\left (4 \, a b^{2} c d + {\left (a^{2} b - b^{3}\right )} c^{2} - {\left (a^{2} b - b^{3}\right )} d^{2}\right )} f x\right )} \tan \left (f x + e\right )}{{\left (a^{4} b + 2 \, a^{2} b^{3} + b^{5}\right )} f \tan \left (f x + e\right ) + {\left (a^{5} + 2 \, a^{3} b^{2} + a b^{4}\right )} f} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Sympy [C] Result contains complex when optimal does not.
time = 0.96, size = 4258, normalized size = 33.79 \begin {gather*} \text {Too large to display} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Giac [B] Leaf count of result is larger than twice the leaf count of optimal. 332 vs.
\(2 (128) = 256\).
time = 0.63, size = 332, normalized size = 2.63 \begin {gather*} \frac {\frac {{\left (a^{2} c^{2} - b^{2} c^{2} + 4 \, a b c d - a^{2} d^{2} + b^{2} d^{2}\right )} {\left (f x + e\right )}}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} - \frac {{\left (a b c^{2} - a^{2} c d + b^{2} c d - a b d^{2}\right )} \log \left (\tan \left (f x + e\right )^{2} + 1\right )}{a^{4} + 2 \, a^{2} b^{2} + b^{4}} + \frac {2 \, {\left (a b^{2} c^{2} - a^{2} b c d + b^{3} c d - a b^{2} d^{2}\right )} \log \left ({\left | b \tan \left (f x + e\right ) + a \right |}\right )}{a^{4} b + 2 \, a^{2} b^{3} + b^{5}} - \frac {2 \, a b^{3} c^{2} \tan \left (f x + e\right ) - 2 \, a^{2} b^{2} c d \tan \left (f x + e\right ) + 2 \, b^{4} c d \tan \left (f x + e\right ) - 2 \, a b^{3} d^{2} \tan \left (f x + e\right ) + 3 \, a^{2} b^{2} c^{2} + b^{4} c^{2} - 4 \, a^{3} b c d + a^{4} d^{2} - a^{2} b^{2} d^{2}}{{\left (a^{4} b + 2 \, a^{2} b^{3} + b^{5}\right )} {\left (b \tan \left (f x + e\right ) + a\right )}}}{f} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________
Mupad [B]
time = 7.12, size = 208, normalized size = 1.65 \begin {gather*} \frac {\ln \left (a+b\,\mathrm {tan}\left (e+f\,x\right )\right )\,\left (-2\,c\,d\,a^2+\left (2\,c^2-2\,d^2\right )\,a\,b+2\,c\,d\,b^2\right )}{f\,\left (a^4+2\,a^2\,b^2+b^4\right )}-\frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )-\mathrm {i}\right )\,\left (c^2+c\,d\,2{}\mathrm {i}-d^2\right )}{2\,f\,\left (-a^2\,1{}\mathrm {i}+2\,a\,b+b^2\,1{}\mathrm {i}\right )}-\frac {\ln \left (\mathrm {tan}\left (e+f\,x\right )+1{}\mathrm {i}\right )\,\left (c^2\,1{}\mathrm {i}+2\,c\,d-d^2\,1{}\mathrm {i}\right )}{2\,f\,\left (-a^2+a\,b\,2{}\mathrm {i}+b^2\right )}-\frac {a^2\,d^2-2\,a\,b\,c\,d+b^2\,c^2}{b\,f\,\left (a^2+b^2\right )\,\left (a+b\,\mathrm {tan}\left (e+f\,x\right )\right )} \end {gather*}
Verification of antiderivative is not currently implemented for this CAS.
[In]
[Out]
________________________________________________________________________________________